<?php
namespace BP\Sys;
require_once("BP/En/Map.php");
class Serial extends Entity {
	public function getIntVal () 
	{
		return $this->GetValStringByKey(SerialAttr::$IntVal);
	}
	public function setIntVal ($value) // [String value]
	{
		$this->SetValByKey(SerialAttr::$IntVal, $value);
	}
	public function getCfgKey () 
	{
		return $this->GetValStringByKey(SerialAttr::$CfgKey);
	}
	public function setCfgKey ($value) // [String value]
	{
		$this->SetValByKey(SerialAttr::$CfgKey, $value);
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map("Sys_Serial", "序列�?");
		$map->setEnType($EnType->Sys);
		$map->setDepositaryOfEntity($Depositary->None);
		$map->AddTBStringPK(SerialAttr::$CfgKey, "OID", "CfgKey",  FALSE ,  TRUE , 1, 100, 10);
		$map->AddTBInt(SerialAttr::$IntVal, 0, "属�??",  TRUE ,  FALSE );
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	public function Gener ($CfgKey) // [String CfgKey]
	{
		$ps = new Paras();
		$ps->Add("p", $CfgKey);
		$sql = (("SELECT IntVal Sys_Serial WHERE CfgKey=" . SystemConfig::getAppCenterDBVarStr()) . "p");
		$val = DBAccess->RunSQLReturnValInt($sql, 0, $ps);
		if (($val == 0))
		{
			$sql = (("INSERT INTO Sys_Serial VALUES(" . SystemConfig::getAppCenterDBVarStr()) . "p,1)");
			DBAccess->RunSQLReturnVal($sql, $ps);
			return 1;
		}
		else
		{
			++$val;
			$ps->Add("intV", $val);
			$sql = (((("UPDATE  Sys_Serial SET IntVal=" . SystemConfig::getAppCenterDBVarStr()) . "intV WHERE  CfgKey=") . SystemConfig::getAppCenterDBVarStr()) . "p");
			DBAccess->RunSQLReturnVal($sql);
			return $val;
		}
	}
}
?>
